﻿using AutoMapper;
using J.Model;
using J.ProductSet.Application.Command.ProductLabelCommand;
using MediatR;
using SqlSugar;

namespace J.ProductSet.Application.CommandHandler.ProductLabelCommandHandler
{
    public class ProductLabelDeleteCommandHandler : IRequestHandler<ProductLabelDeleteCommand, int>
    {
        private readonly ISqlSugarClient _sqlSugarClient;
        public IMapper _mapper;
        public ProductLabelDeleteCommandHandler(ISqlSugarClient sqlSugarClient, IMapper mapper)
        {
            _sqlSugarClient = sqlSugarClient;
            _mapper = mapper;
        }
        public async Task<int> Handle(ProductLabelDeleteCommand request, CancellationToken cancellationToken)
        {
            return await _sqlSugarClient.Deleteable<ProductLabel>(new ProductLabel() { ProductabelId = request.ProductLabelID }).ExecuteCommandAsync();
        }
    }
}
